//package com.yunxin.admin.system.api.warn.task;
//
//
//import com.yunxin.core.domain.service.warn.IWarnHistoryService;
//import com.yunxin.core.utils.infra.support.lock.DistributedLock;
//import com.yunxin.core.utils.infra.support.lock.DistributedLockFactory;
//import com.yunxin.core.utils.infra.support.lock.TaskLockKey;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//@Component
//public class WarnTask {
//
//
//    @Autowired
//    private IWarnHistoryService warnHistoryService;
//
//    @Autowired
//    private DistributedLockFactory distributedLockFactory;
//
//
//    @Scheduled(cron = "0 0 8,9,10,11,12,13,14,15,16,17,18,19,20,21 * * ?  ")
//    public void channel() {
//
//        TaskLockKey warnTaskLoccKey = TaskLockKey.warn_task_locc_key;
//        DistributedLock lock = distributedLockFactory.provideDistributedLock(warnTaskLoccKey.getPrefix());
//        boolean tryLock = lock.tryLock(warnTaskLoccKey.getWaitTime(), warnTaskLoccKey.getReleaseTime(), warnTaskLoccKey.getTimeUnit());
//
//        if (tryLock) {
//            try {
//                warnHistoryService.checkChannel();
//            } finally {
//                if (lock.isHeldByCurrentThread()) {
//                    lock.unlock();
//                }
//            }
//        }
//
//    }
//
//}
